#include "stdafx.hpp"
#include "ColligereLanguageSelectionDlg.hpp"
#include "ColligereApp.hpp"

col::LanguageSelectionDlg::LanguageSelectionDlg ( wxWindow *pParent )
{
	wxXmlResource::Get()->LoadDialog ( this, pParent, "ID_Dialog_Language" );

	wxBitmapComboBox *langs = XRCCTRL ( *this, "ID_BitmapComboBox_Language",
		wxBitmapComboBox );

	wxUint32 us_idx = langs->Append ( _("English (Default)"), wxGetApp().GetIcon 
		( ColligereApp::IconIndex::FlagUs ), new LanguageClientData ( wxLANGUAGE_ENGLISH ) );

	langs->Append ( _("Finnish"), wxGetApp().GetIcon 
		( ColligereApp::IconIndex::FlagFi ), new LanguageClientData ( wxLANGUAGE_FINNISH ) );

	langs->SetSelection ( us_idx );
}

wxLanguage col::LanguageSelectionDlg::GetLanguage() const
{
	const wxBitmapComboBox *langs = XRCCTRL ( *this, "ID_BitmapComboBox_Language",
		wxBitmapComboBox );

	wxASSERT ( langs->GetSelection() != wxNOT_FOUND );

	const LanguageClientData *lang_data = dynamic_cast < const LanguageClientData * > 
		( langs->GetClientObject ( langs->GetSelection() ) );
	wxASSERT ( lang_data );

	return lang_data->GetLanguage();
}